package com.bwie.controller;

import com.bwie.pojo.User;
import com.bwie.service.UserService;
import com.bwie.service.impl.UserServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.LoginFrom;
import com.bwie.vo.LoginVo;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * 用户表(tb_user)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/user/user")
@Api(tags = "用户管理")
public class UserController {
    /**
     * 服务对象
     */
    @Autowired
    private UserService userService;

    /**
     * @author: 鑫仔
     * @description: 发送短信验证码
     * @params: [java.lang.String]
     * @return: com.bwie.utils.R
     * @date: 2025/7/18 14:18
     */
    @ApiOperation("发送短信验证码")
    @PostMapping("sendCode/{mobile}")
    public R sendCode(
            @PathVariable(name = "mobile") String mobile
    ) {
        return userService.sendCode(mobile);
    }

    /**
     * @author: 鑫仔
     * @description: 注册用户
     * @params: []
     * @return: com.bwie.utils.R
     * @date: 2025/7/18 14:26
     */
    @ApiOperation("注册用户")
    @PostMapping("userReg")
    public R userReg(
            @RequestBody @Validated LoginFrom loginFrom
    ) {
        return userService.userReg(loginFrom);
    }

    /**
     * @author: 鑫仔
     * @description: 用户登录
     * @params: [com.bwie.vo.LoginVo]
     * @return: com.bwie.utils.R
     * @date: 2025/7/18 16:48
     */
    @PostMapping("userLogin")
    public R userLogin(
            @RequestBody @Validated LoginVo loginVo
    ) {
        return userService.userLogin(loginVo);
    }

    /**
     * @author: 鑫仔
     * @description: 获取商户的用户
     * @params: []
     * @return: com.bwie.utils.R
     * @date: 2025/7/21 14:06
     */
    @PostMapping("getShopUser")
    public R getShopUser(
            @RequestBody PageInfoVo pageInfoVo
    ) {
        return userService.getShopUser(pageInfoVo);
    }

}
